package com.jy.api.controller;

import com.jy.api.dao.StoreIpAddressDao;
import com.jy.api.service.StoreIpAddressService;
import com.jy.api.signUpReq.StoreIpReq;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

/**
 * Created by xiaohua on 2019/4/2.
 */
@Slf4j
@RestController
@RequestMapping("v1/ip")
public class StoreIpAddressController {

    @Autowired
    private StoreIpAddressService storeIpAddressService;

    @GetMapping("get-ip")
    public ResponseEntity getAllIp(@RequestParam("storeId") String storeId){
        return ResponseEntity.ok(storeIpAddressService.findAllIp(storeId));
    }

    @PostMapping("change-ip")
    public ResponseEntity changeIp(@RequestBody StoreIpReq req){
      return ResponseEntity.ok(storeIpAddressService.addIp(req)) ;

    }

    @PostMapping("delete-ip")
    public ResponseEntity deleteIp(@RequestBody StoreIpReq req){
        return ResponseEntity.ok(storeIpAddressService.deleteIp(req.getId()));
    }




}
